package com.teaphy.coroutinecrawler.flow.operators.filter


import kotlinx.coroutines.flow.*
import kotlinx.coroutines.*

fun main() = runBlocking {

    flow {
        var num = 0
        while (true) {
            emit(num)
            num++
            delay(100)
        }
    }.onStart { println("flow -> start") }
        .onCompletion { println("flow --> completion: $it") }
        .onEach { println("onEach: $it") }
        .takeWhile { it < 2 }
        .collect {
            println("receive: $it")
        }
}
